import axios from "axios";

const requestUtil = axios.create({
    baseURL: "http://47.115.208.111:8080",
})

// 请求拦截器
requestUtil.interceptors.request.use(request => {
    // 如果localstorage中token不为空则添加到协议头
    if (!localStorage.getItem('token')) {
        request.headers['Authorization'] = localStorage.getItem('token')
    }
    return request
}, err => {
    return Promise.reject(err)
})

// 相应拦截器
requestUtil.interceptors.response.use(res => {
    return res
}, error => {
    return Promise.reject(error)
})

export default requestUtil;